{% extends "admin/change_form.html" %}
{% load i18n adminmedia %}


{% block after_related_objects %}
{% if change %}
  <fieldset class="module aligned">
  <h2>{% trans "Menu Items" %}</h2>
  
  <div class="form-row" >
  	  <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10"/> <a href="items/add/">{% trans "Add an item" %}</a>
  </div>
  
  <style type="text/css">
      .form-row tbody tr:hover{
          background-color: #ffffbe;
      }
  </style>
  
  <div class="form-row" >
	  <table cellspacing="0" width="100%">
		<thead>
			<tr>
				<th width="50%">{% trans "Name" %}</th>
				<th>{% trans "Url" %}</th>
				<th width="40" colspan="2">{% trans "Move" %}</th>
			</tr>
		</thead>

		<tbody>
		  {% for menu_item in original.root_item.get_flattened %}
			<tr class="{% cycle 'row1' 'row2' %}">
			
				{% if forloop.first %}
					<td colspan="4">
						{% trans "[Root]" %}
					</td>
				{% else %}
					<td>
						<a href="items/{{ menu_item.pk }}/">{{ menu_item.name_with_spacer|safe }}</a>
					</td>
					<td>
						{{ menu_item.url }}
					</td>

                    {% if menu_item.has_siblings %}
                        {% ifnotequal menu_item.rank menu_item.siblings.count %}
                            <td width="20" align="center"><a href="items/{{ menu_item.pk }}/move_down/"><img src="{% admin_media_prefix %}img/admin/arrow-down.gif" border="0" alt="{% trans 'Down' %}"/></b></td>
                        {% else %}
                            <td width="20">&nbsp;</td>
                        {% endifnotequal %}

                        {% ifnotequal menu_item.rank 0 %}
                            <td width="20" align="center"><a href="items/{{ menu_item.pk }}/move_up/"><img src="{% admin_media_prefix %}img/admin/arrow-up.gif" border="0" alt="{% trans 'Up' %}"/></a></td>
                        {% else %}
                            <td width="20">&nbsp;</td>
                        {% endifnotequal %}
                    {% else %}
                        <td width="20">&nbsp;</td><td width="20">&nbsp;</td>
                    {% endif %}
				{% endif %}
			</tr>
		  {% endfor %}
		</tbody>
	  </table>
  </div>
  </fieldset>
{% endif %}
{% endblock %}
